package com.scirillo.frases;
import com.scirillo.frases.notification.FrasesNotificationManager;
import com.scirillo.frases.preference.FrasesPreferenceManager;
import com.scirillo.frases.util.Util;
import android.app.Application;

public class FrasesApplication extends Application{
	
	@Override
	public void onCreate() {	
		super.onCreate();
		FrasesNotificationManager.init(getApplicationContext());
		FrasesPreferenceManager.SetAppContext(this);
		Util.getInstance().setCurrentContext(getApplicationContext());	
		crateFrases();
		Util.getInstance().getCurrentFraseIndex();
		//Util.getInstance().displayNotification();
	}
	
	public void crateFrases(){
//		String[] frases = Util.getInstance().getCurrentContext().getResources().getStringArray(R.array.frases);
//		String where = DataProvider.Frase._ID +" > "+frases.length;
//		getApplicationContext().getContentResolver().delete(DataProvider.Frase.CONTENT_URI, where, null);
//		
//		for(int i=0; i<frases.length; i++){
//			ContentValues values = new ContentValues();
//			values.put(DataProvider.Frase.TEXT, frases[i]);	
//			getApplicationContext().getContentResolver().insert(DataProvider.Frase.CONTENT_URI, values);
//		}
	}
	
	@Override
	public void onTerminate() {
	   	Util.getInstance().saveCurrentFraseIndex();	   
		super.onTerminate();
	}

}
